var regex_mobile = /^[1][3,4,5,7,8,9][0-9]{9}$/;
var hySms = {
	getVerifyCode : function(showTargetId, kaptchaType, mobile) {
		var url = urlPath+"api/kaptcha/getVerification?mobile="+mobile+"&kaptchaType="+kaptchaType+"&"+ new Date().getTime();
		$(showTargetId).attr("src", url);
	},
	getMobileSms : function(mobile, verifyCode, type) {
		var bSend = false;
		if (verifyCode == null || verifyCode == '') {
			layer.msg("请输入图形验证码");
			return;
		}
		 if (!mobile) {
			layer.msg("手机号不能为空！");
			return;
		}
		var ajaxParams = {
			async : false,
			type : "POST",
			url : "api/sendSms"
		};
		var params = {
			type : type,
			verifyCode : verifyCode,
			mobile : mobile
		};
		commonAjax(ajaxParams, params, null, function(data) {
			if (data.code == 0) {
				layer.msg('短信发送成功，请查看手机获取验证码');
			} else {
				layer.msg(data.msg);
				return;
			}
			bSend = true;
			return;
		}, null);
		return bSend;
	},
	smsLogin:function(mobile, smsCode, verifyCode){
		var isLogin = false;
		var ajaxParams = {async: false, type: "POST", url: "api/user/sms_login"};
		var params = {
				"mobile": mobile, 
				"smsCode": smsCode, 
				"verifyCode": verifyCode
			};
		commonAjax(ajaxParams, params, null, function (data) {
			layer.msg(data.msg);
			if (data.code == 0) {
				data = data.data;
				saveLocalCookieUserId(data.id, data.username, data.nickname, data.mobile, data.gender, data.birth, data.header, data.isCertification, data.realname, data.cardNo, data.createTime, data.isOrgan);
				isLogin = true;
			} else {
				isLogin = false;
			}
		}, null);
		return isLogin;
	},
	isMobile:function(mobile){
		if(regex_mobile.test(mobile)){
			return true;
		}else{
			return false;
		}
	}
		
}